home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / inter52f.zip / INT2WHLP.ZIP / INT2WHLP.PAS < prev    next >
Pascal/Delphi Source File  |  1996-10-05  |  48KB  |  1,342 lines

  1. (*
  2.   Interrupt List -> WinHelp converter (c) 1994 by Christian Müller-Planitz
  3.   ------------------------------------------------------------------------
  4.   e-mail address: see CONST "e_mail"
  5.  
  6.  
  7.   The source and the compiled EXE-file can be freely distributed as long as
  8.   no changes are made without my knowledge.
  9.  
  10.   --------------------------------
  11.   Notes:
  12.    The program was tested with INTLIST38 and INTLIST39 and its output
  13.      was successfully compiled with the MS-Help-compiler "HC31.EXE" V3.10.445.
  14.  
  15.    The program needs the file "INTWHLP.DAT" in the 'source' directory.
  16.  
  17.    The program converted all sourcefiles (INTERRUP.* and *.LST) to
  18.      13 RTF files which needed 11MB on my harddrive.
  19.  
  20.    Compiling the RTF-files without compression took 13 minutes in
  21.      a DOS-Window under Win/NT on a 486-50 (if you run it under DOS
  22.      and if you have a fast hardrive cache, it might be faster).
  23.  
  24.    The (uncompressed) compiled HLP-File was approximately 7MB large.
  25.    If you want to create a compressed HLP-file, you have to exchange the
  26.      comments in the generated help-project file ("RB.HPJ"). Compressing
  27.      reduces the size of the HLP-file to 3MB but it takes
  28.      *more* (?? 28MB ??)  space on your harddrive while compiling.
  29.      In order to speed up compiling the compressed file, I've included a
  30.      temporary file ("INTWIN.PH") of the helpcompiler in this archive.
  31.      Copy this file into the directory containing all the RTF files
  32.      before starting the compiler. This file is specific for INTERLIST39, so
  33.      if you want to get maximal compression in future versions, remove it.
  34.  
  35.    After the compilation finishes, you will find the file "INTWIN.HLP".
  36.      Start Windows, create an icon in the program manager and double-click on it.
  37.  
  38.    Version 1.11:
  39.    The compressed INTWIN.HLP file compiled from Ralf Brown's Interrupt List
  40.      release 42 occupies appr. 4.6 MB.
  41.  
  42.   --------------------------------
  43.  
  44.    If you find this program usefull, if it does not work or if you have ideas
  45.    how to expand its functionality, feel fee to write an e-mail to me.
  46.  
  47.    As usual, I do not take any responsibility for possible damages done by
  48.    this program.
  49.  
  50.  
  51.   Two questions and their answers :
  52.   ---------------------------------
  53.    WHY is the HLP-file so large ?
  54.      In contrast to other programs that convert the interrupt list to
  55.      DOS-based hypertext systems, this program generates a large
  56.      index file that allows you to search for keywords.
  57.  
  58.    WHY did I wrote this program in Pascal and not in C ?
  59.      I think Pascal is a pretty nice language for small projects.
  60.      Another reason is the availability of efficient string handling under Pascal.
  61. *)
  62.  
  63. {$A+,B-,D+,E-,F-,I+,L+,N-,O-,R-,S-,V-}
  64. {$M 16384,25000,200000}
  65. (* minimum heap estimate (1994): 60*(6+10)+(30+40)*(43+10)+50*256=16770 *)
  66. (* (average entry size times (number of entries + 10) for FLAGS, CATEGORIES,
  67.    and CATEGORYKEYS entries) or times 256 for titles.
  68.    Each string in the [*ALIASES] sections requires (length of string) + 5.
  69. *)
  70.  
  71. Program INT2WHLP;
  72.  
  73. uses DOS;
  74.  
  75. { Version 1.00 - 1994
  76.   v. 1.01 -
  77.   v. 1.01a - 1994-02-16:
  78.     published with Ralf Brown's Interrupt List release 40.
  79.   v. 1.02 - 1994-04-07:
  80.     Changed program name from RB2HLP/INTWHLP to INT2WHLP.
  81.     Reduced the amount of RTF control codes.
  82.     Introduced program parameter controlled behaviour.
  83.     Improved flexibility by use of constants for parts of the control.
  84.     Changed and added some windows.
  85.     Extended search key facilities.
  86.   v. 1.03 - 1994-04-17:
  87.     Expanded/Compressed index switch.
  88.     Multi columns compressed index.
  89.     Interrupt titles OVERVIEW.LST.
  90.   v. 1.04 - 1994-04-29:
  91.     Configuration file including:
  92.       Program parameters can be defined in the configuration file. Such
  93.         definitions are overriden by program parameters.
  94.       Several WINHELP parameters, like font and size, can be specified.
  95.       Supplementary information "windows" can be included.
  96.       An ALIAS list can be compiled and written to the HPJ file.
  97.       A BUILDTAG list can be copied from the configuration to the HPJ file.
  98.   v. 1.05 - 1994-05-07:
  99.     Reconsidered default directories.
  100.   v. 1.06 - 1994-05-26:
  101.     Cross-references to tables.
  102.   v. 1.07 - 1994-05-29:
  103.     Edited procedure explain.
  104.     Skip "Section" file break sections (from a "--------!-Section--.."
  105.       divider line up to the next divider line).
  106.     Executable code released with Interrupt List release 41.
  107.     (ProgVers erroneously = '1.06').
  108.   v. 1.08 - 1994-07-10:
  109.     Tables as separate topics.
  110.   v. 1.10 - 1994-07-20:
  111.     Interrupt List release number dependent compilation.
  112.     Published with Interrupt List release 42.
  113.   v. 1.11 - 1994-09-20:
  114.     [INTWINCONFIG] section in configuration file.
  115.   v. 1.12 - 1994-11-04:
  116.     Test for long graphics lines in ReadLine().
  117.     Published with Interrupt List release 43.
  118.   v. 1.13 - 1994-12-26:
  119.     Transformation of DOS graphics in ReadLine().
  120.     Check for duplicate keywords (from CATEGORYKEYS) in NewHlpPage().
  121.     Secondary register references as keywords.
  122.     Separate RTF files for interrupts and tables, check for direct/inderect
  123.       references to tables from current interrupt.
  124.   v. 1.14 - 1995-03-07:
  125.     Return errorlevel 1 for warnings and >= 2 for errors.
  126.   v. 1.15 - 1995-05-29:
  127.     Avoid empty topic in the beginning of .RTF files.
  128.         Made more tools-tolerant: RTF files for expanded and compressed
  129.         indexes reversed. It is easier for some tools to digest the very
  130.         long expanded index when it is compiled at a later state so all its
  131.         phrases are already known.
  132.     [BAGGAGE] section handling.
  133.     Expanded list of registered warnings.
  134.     Copyright message and credits window include Bent Lynggaard as
  135.     coauthor.
  136.   v. 1.16 - 1995-07-31:
  137.     Christian's new e-mail address.
  138.   v. 1.17 - 1996-01-25:
  139.     Fixed bug in NewHelpPage (bad search keys for AH = xx + secondary reg.).
  140.         Switch to inhibit long search keys for INT topics (in order to support
  141.         limited capacity in WinHelp 4.0).
  142.   v. 1.18 - 1996-10-05:
  143.     Shortcut from Credits topic to Interrup.1st Contact Info.
  144.         Insert icon interrup.ico if it is available in current, INT2WHLP home,
  145.         or source directory.
  146.         intwin.ph no longer included in package, instead download interNNz.zip.
  147. }
  148.  
  149. const
  150.   progName  = 'INT2WHLP';
  151.   progVers  = '1.18';
  152.   hfName    = 'INTWIN'; { helpfile name }
  153.   copyright = 'Copyright (C) 1994-1996 by Christian Müller-Planitz and Bent Lynggaard';
  154.   e_mail    = '"cmp@cs.utah.edu"';
  155.     { e-mail address in Intro/Explain windows }
  156.   e_mailCredits = '"cmp@cs.utah.edu"';
  157.     { e-mail address in the Credits window }
  158.   e_mailCredits2 = '"bent.lynggaard@risoe.dk"';
  159.     { e-mail address in the Credits window, coauthor }
  160.  
  161.   { the strings ack01 ... are displayed in the Credits window }
  162.  
  163.   { thanks to (excuse the format): }
  164.   ack01 = '';
  165. (* The following line is a template for an entry:
  166.   '\par{\b <name>} <reason for the entry>';
  167. *)
  168.   ack02 = '';
  169.   ack03 = '';
  170.   ack04 = '';
  171.   ack05 = '';
  172.   {if extended, update procedure "Credits"}
  173.  
  174.   {"errorlevel" constants:}
  175.   aliasErr    = 241; (* alias not found, or table exceeded *)
  176.   fileErr    = 242; (* cannot open file *)
  177.   formatErr    = 243; (* table exceeded, or fatal error in input file *)
  178.   paramErr    = 244; (* error in program parameter *)
  179.   rtfErr    = 245; (* unable to open output file *)
  180.   userErr    = 240; (* terminated by user *)
  181.  
  182. {$I INT2WHLP.INC }
  183.  
  184.   Procedure NewHlpPage(VAR F : Text; S, ID, BrowseID : String; Classification : Char);
  185.     label
  186.       deleteDone;
  187.     type
  188.       intRec = record (* used for fast test and transfer of string *)
  189.     ln: byte;    (* string length *)
  190.     l: longint;  (* 'INT ' *)
  191.     n: word;     (* 'nn' *)
  192.     c7: char;    (* ' ' *)
  193.     l2: longint; (* 'ahal' or 'List' *)
  194.     c12: char;   (* ' ' *)
  195.     w: word;     (* '- ' *)
  196.       end; (* record intRec *)
  197.       nnRec = record ln: byte; w: word; (* for 'nn' *) end;
  198.       ahalRec = record ln: byte; l: longint; (* for 'ahal' *) end;
  199.     const
  200.       linebreak = #13#10'\par\tab';
  201.       intC = ord('I')+ord('N')*$100+ord('T')*$10000+ord(' ')*$1000000;
  202.       listC = ord('L')+ord('i')*$100+ord('s')*$10000+ord('t')*$1000000;
  203.       sepC = ord('-')+ord(' ')*$100;
  204.       int:  string[3] = 'nn';   (* preset length to 2, never changed *)
  205.     VAR
  206.       intR: nnRec absolute int; (* type cast *)
  207.       p,q : Word;
  208.       func: string[5];
  209.       funcR: ahalRec absolute func; (* type cast *)
  210.       ss: string;
  211.       ssR: intRec absolute ss;
  212.  
  213.     Procedure FootNote(Note: Char; ID : String);
  214.       begin
  215.     writeln(F, '{', Note,'}{\footnote ',Note,' ', ID, '}');
  216.       end;
  217.  
  218.  
  219.     procedure insertInt;
  220.       begin
  221.     insert('INT '+int+equStr+func+';'+int+' '+func+';',ss,11);
  222.       (* "INT nn Ar = XXxx;nn XXxx;"  (XXxx = ahal, ah, or --al) *)
  223.     if equStr[3]='L' then delete(ss,21+equBlanks,2);
  224.       (* "--" from AL = --al *)
  225.     insert(copy(ss,18,6+equBlanks+2*ord(equStr[3]='X')),ss,11);
  226.       (* "Ar = XXxx;" *)
  227.       end; (* procedure insertInt in NewHlpPage *)
  228.     procedure insertSecReg(p, l: word);
  229.     (* duplicates part of SS and inserts secondary register *)
  230.       begin
  231.     insert(copy(ss,p,l),ss,p); (* duplicate *)
  232.     insert(secReg,ss,p+l+l-1); (* SXnnnn *)
  233.     insert(secReg,ss,p+l+p-5);
  234.     insert(equStr2,ss,p+l+p-2); (* SX = nnnn *)
  235.     insert(copy(secReg,2,7)+';',ss,p);   (* SXnnnn; *)
  236.     insert(equStr2,ss,p+2);    (* SX = nnnn; *)
  237.       end; (* procedure insertSecReg in NewHlpPage *)
  238.  
  239.     begin
  240.       PageRTF(F); (* insert '\page' if appropriate *)
  241.       writeln(F, '\pard\keepn\li'+indent+'\fi-'+indent);
  242.       FootNote('#', ID);
  243.       if S<>'' then FootNote('$', S);
  244.       if BrowseID<>'' then FootNote('+', BrowseID);
  245.       if (Classification <> nullClassification) then begin
  246.     ss:=s;
  247.     if (ssR.l=intC) AND (ssR.c7=' ') then begin
  248.       if (length(ss)>14) AND (ssR.c12=' ') AND (ssR.w=sepC) then begin
  249.         (* insert highlight in s *)
  250.         insert('}}',s,7);
  251.         insert('{'+highlightInt+'{',s,1);
  252.           (* 2nd '{' terminates attribute, a ' ' distorts if attrib. is empty *)
  253.         (* insert tiny, short, and full form of INT *)
  254.         intR.w:=ssR.n;   (* length of "int" is preset to 2 *)
  255.         (* same as "int:=copy(ss,5,2);": nn from INT nn ahal - xxxx ... *)
  256.         funcR.l:=ssR.l2;
  257.         funcR.ln:=4;     (* func = 'ahal' *)
  258.         ss[7]:=';';      (* INT nn;ahal - xxxx ... *)
  259.         ss[8]:=int[1];
  260.         ss[9]:=int[2];
  261.         ss[10]:=';';     (* INT nn;nn;l - xxxx ... *)
  262.         delete(ss,11,4); (* INT nn;nn;xxxx ... *)
  263.         if func<>'----' then begin
  264.           if func[3]='-' then begin equStr[3]:='H'; func[0]:=#2; end
  265.           else if func[1]='-' then equStr[3]:='L'
  266.           else equStr[3]:='X';
  267.           insertInt;
  268.     (* INT nn;nn;AX = ahal;INT nn AX = ahal;nn ahal;xxxx ... or
  269.        INT nn;nn;AH = ah;INT nn AH = ah;nn ah;xxxx ... or
  270.        INT nn;nn;AL = al;INT nn AL = al;nn --al;xxxx ...
  271.     *)
  272.           if equStr[3]='H'then begin
  273.         insert(copy(ss,29+equBlanks+equBlanks,6)+'--',
  274.           ss,35+equBlanks+equBlanks);
  275.         insert('AX'+equStr2+copy(ss,39+equBlanks+equBlanks,5),
  276.           ss,44+equBlanks+equBlanks);
  277. (* INT nn;nn;AH = ah;INT nn AH = ah;nn ah;nn ah--;AX = ah--;xxxx ... *)
  278.           end; (* equStr[3]='H' *)
  279.           (* duplicate INT nn Ar = ... and insert secondary register
  280.          if appropriate.
  281.           *)
  282.           if secReg<>'' then case equStr[3] of
  283.         'X': insertSecReg(19+equBlanks, 23+equBlanks);
  284.         'H': insertSecReg(17+equBlanks, 19+equBlanks);
  285.         else insertSecReg(17+equBlanks, 21+equBlanks);
  286.           end; (* if secReg<>'' then case equStr[3] of *)
  287.           if equStr[3]='X' then begin (* insert also the AH values *)
  288.         equStr[3]:='H';
  289.         func[0]:=#2;
  290.         insertInt;
  291. (* INT nn;nn;AH = ah;INT nn AH = ah;nn ah;AX = ahal;INT nn AX = ahal;nn ahal;xxxx ... *)
  292.           end; (* if equStr[3]='X' *)
  293.         end (* if func<>'----' *)
  294.         else if secReg<>'' then insertSecReg(1, 10);
  295.         if NOT longKeys then repeat
  296.         (* disable long keys by deleting them. It is not very efficient
  297.            to insert search keys and then delete them again, however,
  298.            this was introduced at a late state due to restrictions in
  299.            WinHelp v. 4.00, and implemented the easy way. The long and
  300.                short formats in the preceding code are so integrated that
  301.                it would take hours to write a more efficient implementation.
  302.         *)
  303.           p:=pos('INT ',ss);
  304.           if p=0 then goto deleteDone;
  305.           q:=p+5;
  306.           while ss[q]<>';' do inc(q);
  307.           delete(ss,p,succ(q-p));
  308.         until false;
  309.     deleteDone:
  310.       end (* if length(ss)>14 ... *)
  311.       else if (length(s)=11) and (ssR.l2=listC) then begin
  312.         insert(copy(ss,1,6)+';',ss,1); (* INT nn;INT nn List *)
  313.         insert(copy(ss,5,3),ss,8); (* INT nn;nn;INT nn List *)
  314.       end; (* else if ... *)
  315.     end; (* if (ssR.l=intC) ... *)
  316.     if Classification=tableClassification then begin
  317.       delete(ss,1,8); (* 'II SUBF ' *)
  318.       insert('#'+currentTable+';',ss,1);
  319.     end (* if Classification=tableClassification *)
  320.     else repeat
  321.       p := POS(' - ', ss);
  322.       if p <> 0 then
  323.         begin
  324.           ss[p] := ';';
  325.           delete(ss,succ(p),2);
  326.         end;
  327.     until p=0;
  328.     if (Classification <> InvalidClassification)
  329.         AND (Classification > ' ') then begin
  330.       if categoryKeyStrings[Classification]^<>'' then begin
  331.         (* check for duplicate before inserting *)
  332.         p:=pos(categoryKeyStrings[Classification]^,ss);
  333.         q:=length(categoryKeyStrings[Classification]^);
  334.         if (p=0) OR ((p+q<>length(ss)) AND (ss[p+q]<>';')) then
  335.           insert(categoryKeyStrings[Classification]^+';',ss,1);
  336.       end; (* if categoryKeyStrings[Classification]^<>'' *)
  337.       if (Classification<'A') OR (Classification>'Z') then
  338.         insert(Classification+';',ss,1)
  339.       else insert(Classification+'!;',ss,1);
  340.     end; (* if (Classification<>InvalidClassification) ... *)
  341.     FootNote('K', SS);
  342.       end; (* if (Classification<>nullClassification) *)
  343.  
  344.       write(F, '{\f0'+headerAttrib,headerSize,' ');
  345.       if classification=specialClassification then write(F, indexHeader);
  346.       writeln(F, S,'}');
  347.       writeln(F, '\par\pard\keep');
  348.  
  349.     end;
  350.  
  351.  
  352.   Procedure AddTopic(VAR F: Text; ST, S, ID: String);
  353.   { print: ST as a string (normally "\par " for new line), S as a hotspot,
  354.     ID as the corresponding jump address or macro.
  355.   }
  356.     const sp: array[0..7] of string[7] =
  357.       ('       ','      ','     ','    ','   ','  ',' ','');
  358.     var p: integer;
  359.     begin
  360.       repeat
  361.     (* detab S, otherwise the string cannot be selected with the cursor
  362.        in a tab position.
  363.     *)
  364.     p:=pos(#9,S);
  365.     if p<>0 then begin S[p]:=' '; insert(sp[(p-1) AND 7],S,p); end;
  366.       until p=0;
  367.       writeln(F, ST,'{\uldb ', S, '}{\v ', ID, '}');
  368.     end;
  369.  
  370.  
  371.   Procedure CheckKeyWords(VAR s : STring);
  372.     CONST KeyWords = 11;
  373.     CONST Keys : Array[1..KeyWords] of String[10] = ('Desc:', 'Notes:',
  374.       'Note:', 'Warning:', 'Index:', 'SeeAlso:', 'Return:', 'BUG:', 'BUGS:',
  375.       'Program:', 'Range:');
  376.     CONST IStr = '{\b ';
  377.     VAR q,p : Integer;
  378.  
  379.     begin
  380.  
  381.       if length(s)<251 then for q:= 1 to KeyWords do
  382.     begin
  383.       p := POS(Keys[q], S);
  384.       if p <> 0 then
  385.         begin
  386.           insert(IStr, S, p);
  387.           insert('}', S, p+Length(Keys[q]) + Length(IStr));
  388.           exit;
  389.         end;
  390.     end;
  391.     end;
  392.  
  393.  
  394.   Function GetSpecialNote(Note : Char)  : String;
  395.     begin
  396.       if flagStrings[Note]^='' then GetSpecialNote:='<unknown note in header>'
  397.       else GetSpecialNote:=flagStrings[Note]^;
  398.     end;
  399.  
  400.  
  401. procedure insertQueued;
  402.   var i,j: word;
  403.   begin
  404.     if (indexColumns>1) OR (queuedEntry='') then exit;
  405.     val('$'+lastSection,i,j);
  406.     if singlesInMain AND (INTcounts[i]=1) then
  407.       AddTopic(IndexFile, nl, queuedEntry, lastSection+'_1')
  408.     else AddTopic(IndexFile, nl, title, lastSection+'_0');
  409.     queuedEntry:='';
  410.   end; (* procedure insertQueued *)
  411.  
  412. function inArray(n: integer; var arr: tableArray; var top: integer): boolean;
  413. (* returns true if n is in arr, else false *)
  414.   var i: integer;
  415.   begin
  416.     i:=1;
  417.     while (i<=top) AND (arr[i]<>n) do inc(i);
  418.     inArray:=i<=top;
  419.   end; (* function inStack in function ProcessIntList *)
  420.  
  421. procedure toArray(n: integer; var arr: tableArray; var top: integer);
  422. (* inserts n in arr if not already present *)
  423.   begin
  424.     if inArray(n, arr, top) then exit;
  425.     if top=tableArraySize then errorExit('Table array exceeded',formatErr);
  426.     inc(top);
  427.     arr[top]:=n;
  428.   end; (* procedure toStack in function ProcessIntList *)
  429.  
  430.   Function ProcessIntList(FName : PathStr) : Boolean;
  431.     LABEL STOP, error_Exit, endOfLoop, table, fobi, noTable;
  432.     type
  433.       kind = (firstPart,inOverview,inFlags,inCategories,inKeys,
  434.     inFileBreakSection,pastTest);
  435.       tableId = array[1..4] of char;
  436.       sRec = record
  437.     l: byte; (* length *)
  438.     w: word; (* with '(T' *)
  439.     d: longint; (* with 'able' *)
  440.     c1: char; (* ' ' *)
  441.     ti: tableId;
  442.     c2: char; (* ')' *)
  443.       end; (* record sRec *)
  444.       castRec = record
  445.     l: byte;
  446.     case byte of
  447.       1: (w: word);
  448.       2: (d: longint);
  449.       3: (c: char (* space *); r: word; rv: longint);
  450.       end; (* record castRec *)
  451.       dividerRec = record
  452.     s: string[8];    (* '--------' *)
  453.     cat: char;    (* category *)
  454.     c: char;    (* '-' *)
  455.     w: word;    (* Interrupt number, 2 hex digits *)
  456.     d: longint;    (* sub function, 4 hex digits or '-' *)
  457.     r: word;    (* secondary register name, two letters or '--' *)
  458.     rv: longint;    (* sec. reg. value, 4 hex digits or '-' *)
  459.       end; (* record dividerRec *)
  460.     const
  461.       INTno:     integer = 0;
  462.       bufferString: string = ''; (* transfers part of split string *)
  463.       ta = ord('(')+ord('T')*$100; (* (Table nnnn) *)
  464.       able = ord('a')+ord('b')*$100+ord('l')*$10000+ord('e')*$1000000;
  465.       fo = ord('F')+ord('o')*$100; (* Format of ... *)
  466.       bi = ord('B')+ord('i')*$100; (* Bitfields for ... *)
  467.       Section: String[3] = '--'; (* initialize to length 2 *)
  468.       SubFunc: String[5] = '----'; (* length 4 *)
  469.       allMessages: boolean = false;
  470.  
  471.     VAR
  472.     tP:          ^tableID;
  473.     hLineP,tLineP : ^string; (* pointers to header and (Table) lines *)
  474.     p,q        : integer;
  475.     curTab     : integer;
  476.     lineCount  : word; (* for error report *)
  477.     NewSection : Boolean;
  478.     Classification,c      : Char;
  479.     current    : kind;
  480.     inTable    : boolean;
  481.     table_Id   : String[7];
  482.     tableTitle : String[119];
  483.     s          : String;
  484.     SpecialNote : String;
  485.     sR         : sRec absolute s; (* for type cast *)
  486.     sectionR   : castRec absolute Section;
  487.     subFuncR   : castRec absolute SubFunc;
  488.     secRegR    : castRec absolute secReg;
  489.     dR         : dividerRec absolute s;
  490.  
  491.     F1         : Text;
  492.  
  493.     function isNumber(var ti: tableId): integer;
  494.     (* returns the table number, or negative value if illegal number *)
  495.       var i,res: integer;
  496.       begin
  497.     res:=0;
  498.     for i:=1 to 4 do case ti[i] of
  499.       '0'..'9': res:=res*10+ord(ti[i])-ord('0');
  500.       else begin isNumber:=-1; exit; end;
  501.     end; (* for ... do case ... *)
  502.     isNumber:=res;
  503.       end; (* function isNumber in function ProcessIntList *)
  504.     procedure insertRef;
  505.       begin
  506.     if inTable then AddTopic(TabTopics,nl,'INT '+Section+' '+SubFunc, TopicStr+mainW)
  507.     else if IntTopicStr<>'' then AddTopic(IntTopics,nl,copy(title,1,6),IntTopicStr);
  508.       end; (* procedure insertRef in function ProcessIntList *)
  509.     procedure wrSection; (* show progress *)
  510.       begin write(Section,#13); end;
  511.  
  512.     begin
  513.      {$I-}
  514.       assign(F1, InPath + FName);
  515.       reset(F1);
  516.      {$I+}
  517.       if IOResult <> 0 then
  518.     begin
  519.       ProcessIntList := FALSE;
  520.       EXIT;
  521.     end;
  522.  
  523.       writeln('Processing : ', InPath + FName);
  524.       write(LastSection,#13);
  525.  
  526.       readLine(F1, s);    { ignore copyright in 1st two lines }
  527.       readLine(F1, s);
  528.       lineCount:=2;
  529.       current:=firstPart;
  530.       inTable:=false;
  531.  
  532.       SpecialNote := '';
  533.  
  534.  
  535.       while not(EOF(F1)) do
  536.     begin
  537.       readLine(F1, s);
  538.       inc(lineCount);
  539.       NewSection := (s[1]= '-') and (Pos('--------', s) <> 0);
  540.  
  541.       if NewSection then
  542.         begin
  543.           if inTable then insertRef;
  544.           for p:=1 to tabTop do begin
  545.         q:=tabArray[p];
  546.         if NOT inArray(q, refArray, refTop) then begin
  547.           str(10000+q,table_Id); (* 1nnnn *)
  548.           delete(table_Id,1,1);  (* nnnn  *)
  549.           AddTopic(intTopics,nl,'Table #'+table_Id,'t'+table_Id+tableW);
  550.           inc(insertCounter);
  551.         end; (* if NOT inArray() *)
  552.           end; (* for p:=1 *)
  553.           inTable:=false;
  554.           insertRef;
  555.           if tabTop>maxTabTop then maxTabTop:=tabTop;
  556.           tabTop:=0;
  557.           if refTop>maxRefTop then maxRefTop:=refTop;
  558.           refTop:=0;
  559.  
  560.           SectionR.w:=dR.w; (* chars 11..12 of divider line *)
  561.           SubFuncR.d:=dR.d; (* chars 13..16 of divider line *)
  562.           secRegR.r:=dR.r;  (* chars 17..18 of divider line *)
  563.           if secReg[2]='-' then secReg[0]:=#0
  564.           else begin
  565.         secRegR.rv:=dR.rv; (* chars 19..22 of divider line *)
  566.         if secReg[6]='-' then secReg[0]:=#5 else secReg[0]:=#7;
  567.           end; (* else *)
  568.           Classification := s[9];
  569.           if Classification = '!' then
  570.         begin
  571.           delete(s,1,12);
  572.  
  573.           q:=0;
  574.           while (s[q] <> '-') and (q < Length(s)) do
  575.             Inc(q);
  576.           s[0] := chr(q-1);  { remove '-' chars at the end }
  577.           if s='OVERVIEW' then current:=inOverview
  578.           else if s='FLAGS' then current:=inFlags
  579.           else if s='CATEGORIES' then current:=inCategories
  580.           else if s='CATEGORYKEYS' then current:=inKeys
  581.           else if s='Section' then begin
  582.             current:=inFileBreakSection;
  583.             Section:=LastSection;
  584.             IntTopicStr:='';
  585.             goto endOfLoop; (* skip file break section *)
  586.           end (* if s='Section' *)
  587.           else current:=firstPart;
  588.           (* Interrupt List release 41 does not include OVERVIEW
  589.              and CATEGORYKEYS as sections, but as separate files.
  590.              The program is prepared for this information being
  591.              parts of the List.
  592.           *)
  593.  
  594.           if s = '' then s:= 'Note';   { shit ! }
  595.  
  596.           if EOF(F1)  then   { last line of document ?}
  597.             goto STOP;
  598.           inc(TopicNo);
  599.           str(TopicNo, TopicStr);
  600.         end { if Classification = '!' }
  601.           else
  602.         begin
  603.           if section<>lastSection then begin
  604.             val('$'+section,INTno,q);
  605.             if q<>0 then begin
  606.               writeln('Cannot interpret interrupt number in line ',
  607.             lineCount,': "',section,'".');
  608.               goto error_Exit;
  609.             end; (* if q<>0 *)
  610.           end; (* if section<>lastSection *)
  611.           current:=pastTest;
  612.           readLine(F1, s);
  613.           inc(lineCount);
  614.           inc(INTcounts[INTno]);
  615.           str(INTcounts[INTno], TopicStr);
  616.           insert(section+'_',TopicStr,1);
  617. (* We could compare already here: "while aliasString=s do ..." if we want to
  618.    use the orginal interrupt header line to find aliases. However,
  619.      1. it is easier to identify the original position of an alias line,
  620.      2. it is easier to determine the alias sequense in the config. file,
  621.      3. it is easier to track the reason for a "not found" error, and
  622.      4. the chance for an alias line to be unique is higher
  623.    if we compare after the manipulation of the header line. Also, if we copy
  624.    from the INTWIN index rather than from the original list, the lines are
  625.    already manipulated.
  626. *)
  627.           while (s[8] <> '-') do   { special flags in titel-line ? }
  628.             begin
  629.               if s[8] <> ' ' then
  630.             SpecialNote:=SpecialNote+#13#10'\par '+GetSpecialNote(s[8]);
  631.               delete(s, 8, 1);
  632.             end;
  633.  
  634.           Insert(subFunc+' ', S, 8);
  635.           while aliasString=S do begin
  636.             saveAlias(nextAliasPP,aliasId+TopicStr);
  637.             getNextAlias(aliasP,aliasId,aliasString);
  638.           end; (* while aliasString=S *)
  639.         end; { else (Classification<>'!') }
  640.  
  641.           if LastSection <> Section then
  642.         begin
  643.           if Classification = '!' then begin
  644.             if indexColumns=1 then insertQueued;
  645.             IntTopicStr:='N_'+TopicStr;
  646.             title:='Notes';
  647.             if (notesCount MOD indexColumns)=0 then write(IndexFile,'\par ')
  648.             else  write(IndexFile,'\tab ');
  649.             inc(notesCount);
  650.             writeln(IndexFile,'{\uldb Notes}{\v ',IntTopicStr,'}');
  651.           end (* if Classification = '!' *)
  652.           else begin (* (Classification <> '!'*)
  653.             if INTno<lastINTno then begin
  654.               (* we cannot tolerate inconsistent sorting in a
  655.              multi-column index.
  656.               *)
  657.               writeln('Inconsistent sorting in file ',FName,
  658.             ' line ',lineCount);
  659.               writeln('INT ',section,' appears after INT ',lastSection);
  660.               if indexColumns>1 then begin
  661.             wl('This can be tolerated only with a single column index.');
  662.          error_Exit:
  663.             errorExit('Please correct the file and try again.',fileErr);
  664.               end; (* if indexColumns>1 *)
  665.               wl(#7'It is recommended to correct the file.');
  666.               inc(warnings);
  667.             end; (* if INTno<lastINTno *)
  668.             if INTno<>lastINTno then begin
  669.               wrSection;
  670.               IntTopicStr:=Section+'_0';
  671.               if indexColumns=1 then begin
  672.             insertQueued;
  673.             queuedEntry:=s;
  674.               end; (* if indexColumns=1 *)
  675.               title:=INTtitles[INTno]^;
  676.               if title='' then title:='INT '+Section;
  677.               lastINTno:=INTno;
  678.             end; (* if INTno<>lastINTno *)
  679.           end; (* else (Classification <> '!') *)
  680.  
  681.           if backRef then AddTopic(SubIntFile,nl,'Interrupts','idInterrupts');
  682.             (* don't insert a backward reference the very first time *)
  683.           backRef:=true; (* but in all the rest *)
  684.           NewHlpPage(SubIntFile, title, IntTopicStr,'i:0', specialClassification);
  685.           if twoIndexes AND indexHeaders then
  686.             OutLn(IntFile,'\par '+title);
  687.           LastSection := Section;
  688.         end; { if LastSection <> Section }
  689.  
  690.  
  691.           if TopicNo=1 then c:=specialClassification
  692.         (* The initial Interrupt List section should cary the
  693.            indexHeader.
  694.         *)
  695.           else c:=Classification;
  696.           NewHlpPage(IntTopics, s, TopicStr,'l:0', c);
  697.           if SpecialNote <> '' then
  698.         begin
  699.           writeln(IntTopics, '{\cf0 ', SpecialNote, '}'#13#10'\par ');
  700.           SpecialNote := '';
  701.         end; { if SpecialNote <> '' }
  702.  
  703.           OutLN(IntTopics, '{\cf0 Category: '+ Classification +
  704.         ' - ' + categoryStrings[Classification]^ + '}\par');
  705.           if Classification='!' then setTabs(IntTopics, 8, deciPoints, 10)
  706.         (* we will set tabs in the few Notes, but not in all the
  707.            INT entries.
  708.         *)
  709.           else if markKeys then OutLN(IntTopics,'{\b Inp.:}');
  710.           if twoIndexes then AddTopic(IntFile, indentIndex, s, TopicStr);
  711.           AddTopic(SubIntFile, nl, s, TopicStr);
  712.         end { if NewSection }
  713.       else          { no new section }
  714.        begin
  715.          case current of
  716.            pastTest:     begin
  717.       { this paragraph is un-indented to gain space for code }
  718.       if markKeys then CheckKeyWords(s);
  719.  
  720.       { check the first two characters and react on '(T'[able nnnn)],
  721.     'Fo'[rmat of ...] and 'Bi'[tfields for ...]
  722.       }
  723.       if tables then case sR.w of
  724.     ta: if (length(s)>=12) AND (sR.d=able) AND (sR.c1=' ') AND (sR.c2=')')
  725.       AND (isNumber(sR.ti)>=0) then begin
  726.         hLineP:=@bufferString;
  727.         tLineP:=@s;
  728.       table:
  729.         if eof(F1) then begin
  730.           writeln('Unextected end of file in table at INT ',Section,
  731.         ' Subfunc ',SubFunc);
  732.           wrSection;
  733.           goto Stop;
  734.         end; (* if eof(F1) *)
  735.         readln(F1, bufferString);
  736.         inc(lineCount);
  737.         p:=pos('(Table ',tLineP^);
  738.         if (p=0) OR  (length(tLineP^)<p+11) OR (tLineP^[p+11]<>')')then begin
  739.       noTable:
  740.           inc(missingTableCounter);
  741.           if allMessages OR (missingTableCounter<=missingTableLimit) then begin
  742.         writeln('Missing "(Table nnnn)" in INT ',Section,
  743.           ' Subfunc ',SubFunc,' (line ',lineCount,'):');
  744.         writeln(pred(lineCount):5,s:succ(length(s)));
  745.         writeln(lineCount:5,bufferString:succ(length(bufferString)));
  746.         if missingTableCounter=missingTableLimit then begin
  747.           wl(#13#10'Several missing tables encountered. If '
  748.             +progName+' is used on release 40 or lower');
  749.           wl('of the List, it should be started with the program '
  750.             +'parameter -r40, or with key');
  751.           wl('releaseNo=40 in section [OPTIONS] of the configuration file.');
  752.           write('s=stop; m=messages; else continue without messages: ');
  753.           ProcessTime:=ProcessTime-memL[$40:$6C];
  754.           p:=readKeyWd;
  755.           ProcessTime:=ProcessTime+memL[$40:$6C];
  756.             (* sets ProcessTime "pause" ticks later than original *)
  757.           if word(p)<$100 then writeln (* function key *)
  758.           else begin
  759.             writeln(char(p));
  760.             case upcase(char(p)) of
  761.               'S': errorExit('Terminated by user',userErr);
  762.               'M': allMessages:=true;
  763.             end; (* if ... case ... of *)
  764.           end; (* if word(p)>$ff *)
  765.         end; (* if missingTableCounter=missingTableLimit *)
  766.         wrSection;
  767.           end; (* if allMessages ... *)
  768.           insert(nl,bufferString,1); (* force newline *)
  769.         end (* if (p=0) ... *)
  770.         else begin
  771.           tP:=@tLineP^[p+7];
  772.           curTab:=isNumber(tP^);
  773.           if curTab<0 then goto noTable;
  774.           toArray(curTab, tabArray, tabTop);
  775.           currentTable:=tP^;
  776.           table_Id:='t'+currentTable;
  777.           if inTable then insertRef;
  778.           inTable:=true;
  779.           tableTitle:=Section+' '+SubFunc+' '+hLineP^;
  780.           while tableAliasString=tableTitle do begin
  781.         saveAlias(nextAliasPP,tableAliasId+table_id);
  782.         getNextAlias(tableAliasP,tableAliasId,tableAliasString);
  783.           end; (* while ... *)
  784.           NewHlpPage(TabTopics, tableTitle, table_Id,'t:0', tableClassification);
  785.           if tableWindow then begin
  786.         AddTopic(TabTopics,nl,'Copy to Main',table_Id+mainW);
  787.         OutLn(TabTopics,'');
  788.           end; (* if tableWindow *)
  789.           if sR.w=ta then begin (* bold Table nnnn *)
  790.         s[1]:='{';  (* substitutes '(' *)
  791.         s[12]:='}'; (*   and ')'       *)
  792.         insert('\b ',s,2);
  793.           end (* if sR.w=ta *)
  794.           else begin
  795.         writeln(TabTopics,'\par {\b Table ',currentTable,'}');
  796.         bufferString[0]:=char(pred(p)); (* delete '(Table nnnn)' *)
  797.           end; (* else *)
  798.           AddTopic(TableFile,nl+currentTable+'  ',tableTitle,table_Id);
  799.         end; (* else *)
  800.     end; (* case ta *)
  801.     fo: if pos('Format of ',s)=1 then begin
  802.       fobi:
  803.       hLineP:=@s;
  804.       tLineP:=@bufferString;
  805.       goto table;
  806.     end; (* case fo *)
  807.     bi: if pos('Bitfields for ',s)=1 then goto fobi;
  808.     else begin
  809.       p:=length(s)-4;
  810.       for q:=p downto 1 do begin
  811.         if (s[q]='#') AND ((q=p) OR (s[q+5]<'0') OR (s[q+5]>'9')) then begin
  812.           tP:=@s[q+1];
  813.           curTab:=isNumber(tP^);
  814.           if curTab>=0 then begin
  815.         toArray(curTab, refArray, refTop);
  816.         insert('}{\v t'+tP^+tableW+'}', S, q+5);
  817.         insert('{\uldb ', S, q);
  818.         if (length(s)-q>150) AND (q>20) then begin
  819.           (* we must ensure keeping length(S)<256 *)
  820.           bufferString:=copy(S, q, 255);
  821.           S[0]:=char(pred(q)); (* delete the copied part *)
  822.         end; (* if (length(s)-q>150)... *)
  823.           end; (* if curTab>=0 *)
  824.         end; (* if (s[q]='#')... *)
  825.       end; (* for q=p *)
  826.     end; (* else *)
  827.       end; (* case sR.w of *)
  828.       { indent again }
  829.                  end; (* case pastTest *)
  830.            firstPart:    check1st(s);
  831.            inOverview:   getINTtitle(s,INTtitles);
  832.            inFlags:      scan(s,flagStrings);
  833.            inCategories: scan(s,categoryStrings);
  834.            inKeys:       scan(s,categoryKeyStrings);
  835.            inFileBreakSection: goto endOfLoop;
  836.          end; (* case current of *)
  837.          if inTable then OutLN(TabTopics, s) else OutLN(IntTopics, s);
  838.          if bufferString<>'' then begin
  839.            if inTable then OutLn(TabTopics, bufferString) (* with "newline" *)
  840.            else writeln(IntTopics, bufferString); (* no "newline" (\par ) *)
  841.            bufferString:='';
  842.          end; (* if bufferString<>'' *)
  843.        end; { else (no new section) }
  844.  
  845.       endOfLoop:
  846.     end; { while not(EOF(F1)) }
  847.  
  848.       STOP:
  849.       if inTable then insertRef;
  850.       inTable:=false;
  851.       insertRef;
  852.       close(F1);
  853.       ProcessIntList := TRUE;
  854.     end;
  855.  
  856.  
  857.   Procedure NewPage(VAR F: Text; Title : String);
  858.     VAR TopicStr : String;
  859.  
  860.       begin
  861.     Inc(TopicNo);
  862.     str(TopicNo, TopicStr);
  863.     AddTopic(IndexFile, nl, Title, TopicStr);
  864.     NewHlpPage(F, Title, TopicStr,'p:0', InvalidClassification);
  865.     setTabs(F, 8, deciPoints, 10);
  866.       end;
  867.  
  868.  
  869.   Procedure ProcessPorts(FName : String);
  870.     LABEL STOP;
  871.     VAR i          : integer;
  872.     s          : String;
  873.     TopicStr   : String;
  874.     NewSection : Boolean;
  875.     F1         : Text;
  876.  
  877.  
  878.  
  879.     begin
  880.       defaultDir(FName,InPath);
  881.      {$I-}
  882.       assign(F1, FName);
  883.       reset(F1);
  884.      {$I+}
  885.       if IOResult <> 0 then
  886.     begin
  887.       writeln('Unable to open ', FName);
  888.       EXIT;
  889.     end;
  890.  
  891.       writeln('Processing : ', FName);
  892.  
  893.       i:=length(FName);
  894.       while FName[i]<>'\' do dec(i);
  895.       NewPage(IntTopics, copy(FName,succ(i),255)+' Note');
  896.  
  897.       while not(EOF(F1)) do
  898.     begin
  899.       readLine(F1, s);
  900.       NewSection := (s[1]= '-') and (Pos('---------', s) <> 0);
  901.  
  902.       if NewSection then
  903.         begin
  904.           readLine(F1, s);
  905.  
  906.           if EOF(F1)  then   { last line of document ?}
  907.         goto STOP;
  908.  
  909.           if s <> '' then                { why does this happend }
  910.         NewPage(IntTopics, s);
  911.         end
  912.       else
  913.         begin
  914.          CheckKeyWords(s);
  915.          OutLN(IntTopics, s);
  916.         end;
  917.     end;
  918.  
  919.       STOP:
  920.       close(F1);
  921.     end;
  922.  
  923.  
  924.   Procedure ProcessFile(FName : String; Title : String);
  925.     VAR s          : String;
  926.     F1, F2     : Text;
  927.         interrup1st: boolean;
  928.  
  929.     begin
  930.       defaultDir(FName,InPath);
  931.      {$I-}
  932.       assign(F1, FName);
  933.       reset(F1);
  934.      {$I+}
  935.       if IOResult <> 0 then
  936.     begin
  937.       writeln('Unable to open ', FName);
  938.       EXIT;
  939.     end;
  940.       interrup1st:=pos('INTERRUP.1ST',FName)<>0;
  941.  
  942.       writeln('Processing : ', FName);
  943.       setTabs(IndexFile, 8, deciPoints, 10);
  944.  
  945.       while not(EOF(F1)) do
  946.     begin
  947.       readLine(F1, s);
  948.       if interrup1st AND (pos('-CONTACT_INFO-', s)<>0) then
  949.         insert(#13#10'{K}{\footnote K Ralf Brown}'
  950.               +#13#10'{K}{\footnote K Brown, Ralf}'
  951.               +#13#10'{K}{\footnote K CONTACT_INFO}'
  952.               (* the following is used as JumpKeyword() target from Credits *)
  953.               +#13#10'{K}{\footnote K interrup.1st Contact Info}'
  954.               +#13#10, s, 1);
  955.       OutLN(IndexFile, s);
  956.     end;
  957.  
  958.       close(F1);
  959.     end;
  960.  
  961.  
  962.   Procedure Credits;
  963.     begin
  964.       OutLn(IndexFile,'');
  965.       AddTopic(IndexFile, nl, 'Credits', 'idCredits');
  966.       OutLn(IndexFile,'');
  967.       OutLn(IndexFile,compilationStr);
  968.       NewHlpPage(IndexFile, 'Credits', 'idCredits','m:1', InvalidClassification);
  969.       OutLn(IndexFile,'\pard{\f0'+headerSize+
  970.     '\qc\par Interrupt List (c) by {\b Ralf Brown}'#13#10 { \qc=centered }
  971.         +'{' + header2ndSize + '\par (See '
  972.         +'{\uldb Contact Info in interrup.1st}'
  973.         +'{\v !JumpKeyword(qchPath,"interrup.1st Contact Info")})}\par');
  974.       OutLn(IndexFile,'\par This list was converted from the released ASCII file'#13#10
  975.             + '\par to the Windows Help-Format by \par\par'#13#10
  976.             + '\par {\b Christian M\''81ller-Planitz}'
  977.                     + '{' + header2ndSize + '\par ' + e_mailCredits + '}'
  978.             + '\par and'
  979.                     + '\par {\b Bent Lynggaard}'+header2ndSize);
  980.       OutLn(IndexFile,e_mailCredits2);
  981. (* an alternative format of the last few lines:
  982.             + '\par {\b Christian M\''81ller-Planitz}'
  983.             + '   and   {\b Bent Lynggaard}'+header2ndSize);
  984.       OutLn(IndexFile,e_mailCredits + '  and  ' + e_mailCredits2);}
  985. *)
  986.       if ack01<>'' then begin
  987.     writeIndex('\par\par Thanks to:');
  988.     writeIndex(ack01);
  989.     writeIndex(ack02);
  990.     writeIndex(ack03);
  991.     writeIndex(ack04);
  992.     writeIndex(ack05);
  993.       end; (* if ack01<>'' *)
  994.       writeIndex('\par}');
  995.     end;
  996.  
  997.  
  998. procedure processTopics(n: integer);
  999. (* inserts references to n topics in the CONTENTS main index *)
  1000.   var i: integer; w: string[13]; title,id: string[39];
  1001.   begin
  1002.     for i:=1 to n do begin
  1003.       str(i,w);
  1004.       insert('WINDOW ',w,1);
  1005.       title:='';
  1006.       profileString(w,'title',title,pred(sizeOf(title)));
  1007.       id:='';
  1008.       profileString(w,'id',id,pred(sizeOf(id)));
  1009.       if (title<>'') AND (id<>'') then AddTopic(IndexFile,nl,title,id);
  1010.     end; (* for i:=1 *)
  1011.   end; (* procedure processTopics *)
  1012.  
  1013. procedure processPages(n: integer);
  1014. (* processes n "windows" as defined in the configuration file *)
  1015.   var
  1016.     i,j,wType,files,fType: integer;
  1017.     w: string[13];
  1018.     f: string[17];
  1019.     id: string[17];
  1020.     fId,chain: string[21];
  1021.     title,fTitle: string[39];
  1022.     fileName: pathStr;
  1023.   begin
  1024.     for i:=1 to n do begin
  1025.       str(i,w);
  1026.       insert('WINDOW ',w,1);
  1027.       title:='';
  1028.       profileString(w,'title',title,pred(sizeOf(title)));
  1029.       id:='';
  1030.       profileString(w,'id',id,pred(sizeOf(id)));
  1031.       if (title<>'') AND (id<>'') then begin
  1032.     wType:=1;
  1033.     profileInt(w,'type',wType);
  1034.     files:=1;
  1035.     profileInt(w,'files',files);
  1036.     case wType of
  1037.       1: NewHlpPage(IndexFile,title,id,'f:0',InvalidClassification);
  1038.         (* Single entry windows *)
  1039.       2: NewHlpPage(IndexFile,title,id,'m:9',InvalidClassification);
  1040.         (* Multi entries windows *)
  1041.       3: ; (* nop *)   (* Windows with own contents list *)
  1042.     end; (* case wType of *)
  1043.     for j:=1 to files do begin
  1044.       str(j,f);
  1045.       insert('file ',f,1);
  1046.       fileName:='';
  1047.       profileString(w,f,fileName,pred(sizeOf(fileName)));
  1048.       if fileName<>'' then begin
  1049.         fType:=wType;
  1050.         profileInt(w,f+' type',fType);
  1051.         case fType of
  1052.           1: ProcessFile(fileName,title);
  1053.           2: ProcessPorts(fileName);
  1054.           3: begin
  1055.         (* the RTF file is expecte to be in:
  1056.              a. the current directory.
  1057.              b. the program's home directory
  1058.            if no drive or root is specified.
  1059.         *)
  1060.         if ((length(fileName)<2) OR (fileName[2]<>':'))
  1061.           AND (fileName[1]<>'\') AND (fileName[1]<>'.') then begin
  1062.           if exist(filename) OR NOT exist(homeDir+filename) then
  1063.             insert(currentDir,filename,1)
  1064.           else insert(homeDir,filename,1);
  1065.         end; (* if (fileName[2]<':'... *)
  1066.         fileName:=fExpand(fileName);
  1067.         if NOT exist(fileName) then begin
  1068.           writeln(#7'File ',fileName,' not found, copy to ',currentDir);
  1069.                   inc(warnings);
  1070.                 end; (* if NOT exist(filename) *)
  1071.         writeln(HPJ,fileName); (* include the file name *)
  1072.           end;
  1073.           4: begin (* ASCII file in multi file entry *)
  1074.         str(j,fTitle);
  1075.         str(j,fId);
  1076.         insert(title+' - ',fTitle,1);
  1077.         insert(id+'_',fId,1);
  1078.         chain:=id+':5';
  1079.         profileString(w,f+' title',fTitle,pred(sizeOf(fTitle)));
  1080.         profileString(w,f+' id',fId,pred(sizeOf(fId)));
  1081.         profileString(w,f+' chain',chain,pred(sizeOf(chain)));
  1082.         NewHlpPage(IndexFile,fTitle,fId,chain,InvalidClassification);
  1083.         defaultDir(fileName,currentDir);
  1084.         ProcessFile(fileName,fTitle);
  1085.           end; (* case 4 *)
  1086.         end; (* case fType of *)
  1087.       end (* if fileName<>'' *)
  1088.       else begin
  1089.         writeln(#7'Missing file name for [',w,'] ',f);
  1090.         inc(warnings);
  1091.       end; (* else *)
  1092.     end; (* for j:=1 *)
  1093.       end (* if (title<>'') ... *)
  1094.       else begin
  1095.     writeln(#7'Missing title or identifier in ',w);
  1096.     inc(warnings);
  1097.       end; (* else *)
  1098.     end; (* for i:=1 *)
  1099.   end; (* procedure processPages *)
  1100.  
  1101. procedure processFilter;
  1102.   var d: dirStr;
  1103.   begin
  1104.     PageRTF(IndexFile); (* insert '\page' if appropriate *)
  1105.     writeIndex('\pard');
  1106.     writeIndex('#{\footnote{#} idPartComp}');
  1107.     writeIndex('{\f0'+header2ndSize+' This compilation of the Interrupt List does '+#13#10
  1108.       +'not contain all the information in the List, see the '#13#10
  1109.       +'{\uldb INTERRUP.1ST File}{\v id1st} for the availability of the ');
  1110.     writeIndex('complete list.\par\par');
  1111.     writeIndex('See {\uldb Filter Method}{\v idFlt_meth} and '#13#10
  1112.       +'{\uldb Filter File}{\v idFlt_file} for details.\par}');
  1113.     d:=currentDir;
  1114.     if NOT exist('FLT_METH.RTF') then begin
  1115.       if exist(homeDir+'FLT_METH.RTF') then d:=homeDir
  1116.       else begin
  1117.     writeln(#7'File FLT_METH.RTF not found, copy to ',d);
  1118.     inc(warnings);
  1119.       end; (* else *)
  1120.     end; (* if NOT exist() *)
  1121.     writeln(HPJ,d,'FLT_METH.RTF');
  1122.     NewHlpPage(IndexFile, 'Filter File', 'idFlt_file','flt:1', invalidClassification);
  1123.     processFile(filterFileName,'Filter File');
  1124.   end; (* procedure processFilter *)
  1125.  
  1126. procedure readCategoryKeys;
  1127. (* Opens file CATEGORY.KEY if available, and reads definitions to
  1128.    categoryKeyStrings. Definitions are of the type
  1129.       A - definition A, B - definition B,
  1130.    The definitions are inserted as search keys for the appropriate
  1131.    categories. Note that more than one keyword per entry is accepted,
  1132.    separated by a semicolon, e.g. " c - cachers;spoolers,".
  1133.  
  1134.    Reads also title file OVERVIEW.LST.
  1135.  
  1136.    CATEGORY.KEY and OVERVIEW.LST are separate files in Interrupt List
  1137.    release 41+.
  1138. *)
  1139.   var t: text; s: string;
  1140.   begin
  1141. (*$I-*)
  1142.     assign(t,InPath+'category.key');
  1143.     reset(t);
  1144. (*$I+*)
  1145.     if IOresult<>0 then writeln('Unable to open ',InPath,'CATEGORY.KEY')
  1146.     else begin
  1147.       while NOT eof(t) do begin readln(t,s); scan(s,categoryKeyStrings); end;
  1148.       close(t);
  1149.     end; (* else *)
  1150. (*$I-*)
  1151.     assign(t,InPath+'overview.lst');
  1152.     reset(t);
  1153. (*$I+*)
  1154.     if IOresult<>0 then writeln('Unable to open ',InPath,'OVERVIEW.LST')
  1155.     else begin
  1156.       while NOT eof(t) do begin readln(t,s); getINTtitle(s,INTtitles); end;
  1157.       close(t);
  1158.     end; (* else *)
  1159.   end; (* procedure readCategoryKeys *)
  1160.  
  1161. procedure INTsToIndex;
  1162.   var i,j,k,l: word; s: string[3];
  1163.   begin
  1164.     for k:=0 to pred(indexPages) do begin
  1165.       l:=k*indexRows*indexColumns;
  1166.       for i:=0 to pred(indexRows) do begin
  1167.     OutLn(IndexFile, '');
  1168.     for j:=0 to pred(indexColumns) do begin
  1169.       if INTcounts[l+i+j*16]<>0 then begin
  1170.         write(IndexFile,'{\uldb INT ',HEX(l+i+j*16));
  1171.         if indexColumns=4 then write(IndexFile,' List');
  1172.         write(IndexFile,'}{\v ',HEX(l+i+j*16),'_0}');
  1173.       end (* if INTcounts[]<>0 *)
  1174.       else if indexColumns=4 then write(IndexFile,'\tab ');
  1175.       if j<pred(indexColumns) then write(IndexFile,'\tab ');
  1176.     end; (* for j:=0 *)
  1177.       end; (* for i:=0 *)
  1178.       if k<pred(indexPages) then OutLn(IndexFile, '');
  1179.     end; (* for k:=0 *)
  1180.   end; (* procedure INTsToIndex *)
  1181.  
  1182.   const
  1183.     windows: integer = 0;
  1184.  
  1185.   var
  1186.     i: integer;
  1187.     ch: char;
  1188.  
  1189.   begin
  1190.     Intro;
  1191.     if (paramStr(1)='?') OR (paramStr(1)='-?') OR (paramStr(1)='/?')
  1192.       then Explain; (* and exit *)
  1193.  
  1194.     fSplit(paramStr(0),homeDir,currentDir,currentDir);
  1195.       (* works only with DOS 3.30+ - currentDir is used as a dummy *)
  1196.     currentDir:=fExpand('.');
  1197.     if length(currentDir)>3 then begin
  1198.       inc(currentDir[0]);
  1199.       currentDir[length(currentDir)]:='\';
  1200.     end; (* if length()... *)
  1201.     interpretParameters;
  1202.     initializeArrays;
  1203.     nextAliasPP:=@firstAliasP;
  1204.  
  1205.     if InPath='' then begin
  1206.       write('Source directory: ');
  1207.       readln(InPath);
  1208.     end; (* if InPath='' *)
  1209.     if InPath<>'' then begin
  1210.       ch:=InPath[length(InPath)];
  1211.       if (ch<>':') AND (ch<>'\') then
  1212.     begin inc(InPath[0]); InPath[length(InPath)]:='\'; end;
  1213.     end; (* if InPath<>'' *)
  1214.  
  1215.     if OutPath='' then begin
  1216.       write('Dest. directory (has to be created in advance) : ');
  1217.       readln(OutPath);
  1218.     end; (* if OutPath='' *)
  1219.     if OutPath<>'' then begin
  1220.       ch:=OutPath[length(OutPath)];
  1221.       if (ch<>':') AND (ch<>'\') then
  1222.     begin inc(OutPath[0]); OutPath[length(OutPath)]:='\'; end;
  1223.     end; (* if OutPath<>'' *)
  1224.  
  1225.     ProcessTime:=memL[$40:$6C]; { timer ticks since midnight }
  1226.     findDateAndCopyright;
  1227.     CreateHPJ;
  1228.  
  1229.     OpenRTF(IndexFile, 'INDEX.RTF');
  1230.     NewHlpPage(IndexFile, 'Contents:', 'CONTENTS','m:2', specialClassification);
  1231.  
  1232.     readCategoryKeys; (* reads also titles *)
  1233.     OpenRTF(SubIntFile,'SUBINT.RTF');
  1234.     OpenRTF(IntTopics, 'INTTOPIC.RTF');
  1235.     if twoIndexes then OpenRTF(IntFile, 'INT.RTF');
  1236.  
  1237.     if twoIndexes then
  1238.       AddTopic(IndexFile, nl, 'Interrupt Index',
  1239.     '!IfThenElse(IsMark("Compressed_Index"), '
  1240.     +'`JumpId(qchPath,"idInterrupts")'', `JumpId(qchPath,"idIndex")'')')
  1241.     else AddTopic(IndexFile, nl, 'Interrupts', 'idInterrupts');
  1242.     if tables then AddTopic(IndexFile, nl, 'Tables', 'idTables');
  1243.     AddTopic(IndexFile, nl, 'FILELIST', '1');
  1244.     AddTopic(IndexFile, nl, 'INTERRUP.1ST File', 'id1st');
  1245.     if filtered then begin
  1246.       AddTopic(IndexFile, nl, 'Filter Method', 'idFlt_meth');
  1247.       AddTopic(IndexFile, nl, 'Filter File', 'idFlt_file');
  1248.     end; (* if filtered *)
  1249.  
  1250.     profileInt('WINDOWS','number',windows);
  1251.     processTopics(windows); (* insert Ports, Memory etc. in index *)
  1252.  
  1253.     Credits;
  1254.  
  1255.     if twoIndexes then begin
  1256.       NewHlpPage(IntFile, 'Interrupt Index', 'idIndex','m:3', specialClassification);
  1257.       AddTopic(IntFile, nl, 'Compress index',
  1258.     '!SaveMark("Compressed_Index");JumpId(qchPath,"idInterrupts")');
  1259.       { the program adds all following entries }
  1260.     end; (* if twoIndexes *)
  1261.     NewHlpPage(IndexFile, 'Interrupts', 'idInterrupts','m:4', specialClassification);
  1262.     if twoIndexes then begin
  1263.       AddTopic(IndexFile, nl, 'Expand index','!IfThen(IsMark("Compressed_Index"),'
  1264.     +' `DeleteMark("Compressed_Index")'');JumpId(qchPath,"idIndex")');
  1265.       OutLn(IndexFile, '');
  1266.       if indexColumns>1 then setTabs(IndexFile, succ(ord(indexColumns<=4))*8,
  1267.     deciPoints, pred(indexColumns));
  1268.     end; (* if twoIndexes *)
  1269.  
  1270.     if tables then begin
  1271.       OpenRTF(TableFile, 'TABLE.RTF');
  1272.       OpenRTF(TabTopics, 'TABTOPIC.RTF');
  1273.       NewHlpPage(TableFile,'Tables\f1'+fontSize+'\par\par Tab# INT Func Title',
  1274.     'idTables','m:5', invalidClassification);
  1275.       (* "Tab# INT Func Title" in normal text font and size *)
  1276.     end; (* if tables *)
  1277.  
  1278.     profileList('ALIAS',aliasP); (* read [ALIAS] section from config. file *)
  1279.     getNextAlias(aliasP,aliasId,aliasString); (* get the first one (if any) *)
  1280.     profileList('TABLEALIAS',tableAliasP);
  1281.     getNextAlias(tableAliasP,tableAliasId,tableAliasString);
  1282.  
  1283.     (* process either "interrup.lst" or "interrup.a".."interrup.?" *)
  1284.     if NOT ProcessIntList('interrup.lst') then begin
  1285.       ch := 'a';
  1286.       while ProcessIntList('interrup.'+ch) do inc(ch);
  1287.     end; (* if NOT ProcessIntList() *)
  1288.     if NOT longKeys then writeln(HPJ,'SHORTKEY.RTF');
  1289.       (* include short keyword help topic *)
  1290.  
  1291.     if aliasString<>'' then begin
  1292.       writeln(#7'Alias string not found:'#13#10+'  "',aliasString,'"');
  1293.       inc(warnings);
  1294.       if aliasP<>NIL then
  1295.     wl('One or more alias strings not processed.');
  1296.     end; (* if aliasP<>NIL *)
  1297.     if tableAliasString<>'' then begin
  1298.       writeln(#7'Table alias string not found:'#13#10+'  "',
  1299.     tableAliasString,'"');
  1300.       inc(warnings);
  1301.       if tableAliasP<>NIL then
  1302.     wl('One or more table alias strings not processed.');
  1303.     end; (* if tableAliasP<>NIL *)
  1304.  
  1305.     if indexColumns=1 then insertQueued
  1306.     else INTsToIndex;
  1307.  
  1308.     NewHlpPage(IndexFile, 'INTERRUP.1ST File', 'id1st','f:0', invalidClassification);
  1309.     ProcessFile('interrup.1st', 'INTERRUP.1ST File');
  1310.     if filtered then processFilter;
  1311.  
  1312.     processPages(windows); (* process Ports, Memory etc. *)
  1313.  
  1314.     if firstAliasP<>NIL then begin
  1315.       writeln(HPJ,#13#10'[ALIAS]');
  1316.       processAliasList(firstAliasP);
  1317.     end; (* if (firstAliasP<>NIL)... *)
  1318.     if twoIndexes then closeRTF(IntFile);
  1319.     closeRTF(SubIntFile);
  1320.     closeRTF(IntTopics);
  1321.     if tables then begin
  1322.       closeRTF(TableFile);
  1323.       closeRTF(TabTopics);
  1324.     end; (* if tables *)
  1325.     closeRTF(IndexFile);
  1326.     close(HPJ);
  1327.     if missingTableCounter>=missingTableLimit then
  1328.       writeln(missingTableCounter,' missing tables encountered.');
  1329.     ProcessTime:=memL[$40:$6C]-ProcessTime;
  1330.     writeln('The processing took ',(ProcessTime*10+91) DIV 182,' seconds.');
  1331.       (* 18.2 clock ticks per second, rounded *)
  1332.     i:=(maxTabTop*100) DIV tableArraySize;
  1333.     if i>60 then writeln(i,'% table array usage.');
  1334.     i:=(maxRefTop*100) DIV tableArraySize;
  1335.     if i>60 then writeln(i,'% reference array usage.');
  1336.     if insertCounter<>0 then writeln('Inserted ',insertCounter,' table references.');
  1337.     if warnings<>0 then begin
  1338.       writeln('Issued ',warnings,' warning(s).');
  1339.       halt(1);
  1340.     end; (* if warnings<>0 *)
  1341.   end.
  1342.